namespace DotNetNuke.Entities.Modules
{
    using System;

    public class DesktopModuleInfo
    {
        private string _BusinessControllerClass;
        private string _Description;
        private int _DesktopModuleID;
        private string _FolderName;
        private string _FriendlyName;
        private bool _IsAdmin;
        private bool _IsPremium;
        private string _ModuleName;
        private int _SupportedFeatures;
        private string _Version;

        private void ClearFeature(DesktopModuleSupportedFeature Feature)
        {
            this.SupportedFeatures &= ~(int)Feature;
        }

        private bool GetFeature(DesktopModuleSupportedFeature Feature)
        {
            bool isSet = false;
            if ((this.SupportedFeatures & (int)Feature) == (int)Feature)
            {
                isSet = true;
            }
            return isSet;
        }

        private void SetFeature(DesktopModuleSupportedFeature Feature)
        {
            this.SupportedFeatures |=(int) Feature;
        }

        private void UpdateFeature(DesktopModuleSupportedFeature Feature, bool IsSet)
        {
            if (IsSet)
            {
                this.SetFeature(Feature);
            }
            else
            {
                this.ClearFeature(Feature);
            }
        }

        public string BusinessControllerClass
        {
            get
            {
                return this._BusinessControllerClass;
            }
            set
            {
                this._BusinessControllerClass = value;
            }
        }

        public string Description
        {
            get
            {
                return this._Description;
            }
            set
            {
                this._Description = value;
            }
        }

        public int DesktopModuleID
        {
            get
            {
                return this._DesktopModuleID;
            }
            set
            {
                this._DesktopModuleID = value;
            }
        }

        public string FolderName
        {
            get
            {
                return this._FolderName;
            }
            set
            {
                this._FolderName = value;
            }
        }

        public string FriendlyName
        {
            get
            {
                return this._FriendlyName;
            }
            set
            {
                this._FriendlyName = value;
            }
        }

        public bool IsAdmin
        {
            get
            {
                return this._IsAdmin;
            }
            set
            {
                this._IsAdmin = value;
            }
        }

        public bool IsPortable
        {
            get
            {
                return this.GetFeature(DesktopModuleSupportedFeature.IsPortable);
            }
            set
            {
                this.UpdateFeature(DesktopModuleSupportedFeature.IsPortable, value);
            }
        }

        public bool IsPremium
        {
            get
            {
                return this._IsPremium;
            }
            set
            {
                this._IsPremium = value;
            }
        }

        public bool IsSearchable
        {
            get
            {
                return this.GetFeature(DesktopModuleSupportedFeature.IsSearchable);
            }
            set
            {
                this.UpdateFeature(DesktopModuleSupportedFeature.IsSearchable, value);
            }
        }

        public string ModuleName
        {
            get
            {
                return this._ModuleName;
            }
            set
            {
                this._ModuleName = value;
            }
        }

        public int SupportedFeatures
        {
            get
            {
                return this._SupportedFeatures;
            }
            set
            {
                this._SupportedFeatures = value;
            }
        }

        public string Version
        {
            get
            {
                return this._Version;
            }
            set
            {
                this._Version = value;
            }
        }
    }
}

